<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>cisau信院免费邮--校园邮箱第一品牌</title>
<link rel="shortcut icon" href="<%=basePath %>images/favicon.ico" type="image/x-icon"/>
 <link rel="stylesheet" href="<%=basePath %>js/jPlayer/jplayer.flat.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/bootstrap.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/animate.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/font-awesome.min.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/simple-line-icons.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/font.css" type="text/css" />
  <link rel="stylesheet" href="<%=basePath %>css/app.css" type="text/css" />  
</head>
<script type="text/javascript" src="<%=basePath %>js/jquery.min.js"></script>


<body>

<jsp:include page="top.jsp"></jsp:include>
        <!-- 隐藏域开始 -->
        
        <input type="hidden" name="owner" value="${USER.email }" id="owner">
        
         <!-- 隐藏域结束 -->
          <section class="vbox">
            <section class="scrollable padder">
              <div class="m-b-md">
                
              </div>
              <div class="row" style="margin-left: 150px;">
                


                <div class="col-sm-6" style="min-width: 1500px; min-height: 1000px; ">
             <!-- 发送邮件表单start -->   
                
                  <form name="email" data-validate="parsley" action=""  enctype="multipart/form-data" method="post">
                    <input type="hidden" name="picpath" value="${email.picpath }">
                    <section class="panel panel-default">
                      <header class="panel-heading">
                        <span class="h4">发送邮件</span>
                      </header>
                      <div class="panel-body">
                        

			<!-- 选择好友表单start -->
					<label class="col-sm-2 control-label">选择好友</label>
                           <div class="form-group">
                      
                      <div class="col-sm-10" style="float: left; min-width: 1200px;">

                        <div class="input-group m-b" >
                          
                            <select class="form-control m-b" id="myFriendList" onclick="chooseFriend();">
                            
                               
                           </select>

                          <input type="text" class="form-control" id="receiveMan" readonly="readonly" name="receiveMan">
                        </div>

                        

                        
                      </div>
                    </div>
<!-- 选择好友表单end -->



						              <div class="form-group pull-in clearfix">
                            <div class="col-sm-6">
                              <label class="col-sm-2 control-label">标题：</label>
                              <input type="text" style="margin-left:15px;" name="title" id="title" class="form-control" placeholder="title" required="required">
                            </div>
                            
                          </div>
						


                          
                         <!-- <div class="form-group">
                            <label>Message</label>
                            <textarea class="form-control" rows="6" data-minwords="6" data-required="true" placeholder="Type your message"></textarea>
                          </div>
                         -->



                   <!-- 大输入框start -->
                        <label style="margin-left: 15px;">邮件内容：</label>
					           <div class="form-group" >
                      
                        <div class="col-sm-10">
                        <div class="btn-toolbar m-b-sm btn-editor" data-role="editor-toolbar" data-target="#editor">
                          <div class="btn-group">
                            <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" title="Font"><i class="fa fa-font"></i><b class="caret"></b></a>
                              <ul class="dropdown-menu">
                              </ul>
                          </div>
                          <div class="btn-group">
                            <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" title="Font Size"><i class="fa fa-text-height"></i>&nbsp;<b class="caret"></b></a>
                              <ul class="dropdown-menu">
                              <li><a data-edit="fontSize 5" style="font-size:24px">Huge</a></li>
                              <li><a data-edit="fontSize 3" style="font-size:18px">Normal</a></li>
                              <li><a data-edit="fontSize 1" style="font-size:14px">Small</a></li>
                              </ul>
                          </div>
                          <div class="btn-group">
                            <a class="btn btn-default btn-sm" data-edit="bold" title="Bold (Ctrl/Cmd+B)"><i class="fa fa-bold"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="italic" title="Italic (Ctrl/Cmd+I)"><i class="fa fa-italic"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="strikethrough" title="Strikethrough"><i class="fa fa-strikethrough"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="underline" title="Underline (Ctrl/Cmd+U)"><i class="fa fa-underline"></i></a>
                          </div>
                          <div class="btn-group">
                            <a class="btn btn-default btn-sm" data-edit="insertunorderedlist" title="Bullet list"><i class="fa fa-list-ul"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="insertorderedlist" title="Number list"><i class="fa fa-list-ol"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="outdent" title="Reduce indent (Shift+Tab)"><i class="fa fa-dedent"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="indent" title="Indent (Tab)"><i class="fa fa-indent"></i></a>
                          </div>
                          <div class="btn-group">
                            <a class="btn btn-default btn-sm" data-edit="justifyleft" title="Align Left (Ctrl/Cmd+L)"><i class="fa fa-align-left"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="justifycenter" title="Center (Ctrl/Cmd+E)"><i class="fa fa-align-center"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="justifyright" title="Align Right (Ctrl/Cmd+R)"><i class="fa fa-align-right"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="justifyfull" title="Justify (Ctrl/Cmd+J)"><i class="fa fa-align-justify"></i></a>
                          </div>
                          <div class="btn-group">
                            <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" title="Hyperlink"><i class="fa fa-link"></i></a>
                            <div class="dropdown-menu">
                              <div class="input-group m-l-xs m-r-xs">
                                <input class="form-control input-sm" placeholder="URL" type="text" data-edit="createLink"/>
                                <div class="input-group-btn">
                                  <button class="btn btn-default btn-sm" type="button">Add</button>
                                </div>
                              </div>
                            </div>
                            <a class="btn btn-default btn-sm" data-edit="unlink" title="Remove Hyperlink"><i class="fa fa-cut"></i></a>
                          </div>
                          
                          <div class="btn-group hide">
                            <a class="btn btn-default btn-sm" title="Insert picture (or just drag & drop)" id="pictureBtn"><i class="fa fa-picture-o"></i></a>
                            <input type="file" data-role="magic-overlay" data-target="#pictureBtn" data-edit="insertImage" />
                          </div>
                          <div class="btn-group">
                            <a class="btn btn-default btn-sm" data-edit="undo" title="Undo (Ctrl/Cmd+Z)"><i class="fa fa-undo"></i></a>
                            <a class="btn btn-default btn-sm" data-edit="redo" title="Redo (Ctrl/Cmd+Y)"><i class="fa fa-repeat"></i></a>
                          </div>
                        </div>
                        <div id="editor" onblur="fgai();" class="form-control" style="overflow:scroll;height:150px;max-height:150px">
                        
                        </div>
                    <input type="hidden" name="content" id="contents">
                    <input type="hidden" name="id" id="id">
                     <!-- 这里加一段js，将上面的文本域中的内容传到下面的输入框中 -->
                        <script type="text/javascript">

                            function fgai(){
                            
                            var div=document.getElementById("editor");
                           
                            var input = document.getElementById("contents");
                            input.value=div.innerText;
                           
                          }
                          </script>
                      </div>
                    </div>

			<!-- 大输入框end -->
                        <div class="col-sm-10" style="margin-top: 20px;">
                        		<input type="file" id="uploadFile" name="uploadFile" class="filestyle" data-icon="false" data-classButton="btn btn-default" data-classInput="form-control inline v-middle input-s">
                      	</div>
                      </div>
                      <footer class="panel-footer text-right bg-light lter">
                      <button onclick="caogao();" class="btn btn-success btn-s-xs">存入草稿箱</button>
                        <button onclick="fasong();" class="btn btn-success btn-s-xs">Submit</button>
                      </footer>
                    </section>
                  </form>
                  

			<script type="text/javascript">  
                  function caogao(){
                	  debugger;
//                    document.("表单的name值").action
//                    document.("表单的name值").submit
                    document.email.action='<%=basePath%>email/addToDraft';
                    document.email.submit();
                }
                  function fasong(){
                	  debugger;
//                    document.("表单的name值").action
//                    document.("表单的name值").submit
					var receiveMan = document.getElementById("receiveMan").value;
					var title = document.getElementById("title").value;
					if(receiveMan==""||receiveMan==null){
						alert("收件人不能为空！");
						return false;
					}
					if(title==""||title==null){
						alert("邮件标题不能为空！");
						return false;
					}
                    document.email.action='<%=basePath %>email/sendEmail';
                    document.email.submit();
                }

                  </script>
               <!-- 发送邮件表单end -->   
                  
                </div>
              </div>

              
            </section>
          </section>
          <a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen,open" data-target="#nav,html"></a>

  <script src="<%=basePath %>js/wizard/jquery.bootstrap.wizard.js"></script>
<script src="<%=basePath %>js/wizard/demo.js"></script>
  <script src="<%=basePath %>js/app.plugin.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/jquery.jplayer.min.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/add-on/jplayer.playlist.min.js"></script>
  <script type="text/javascript" src="<%=basePath %>js/jPlayer/demo.js"></script>
   
</body>
 
   <script src="<%=basePath %>js/file-input/bootstrap-filestyle.min.js"></script>
  <script src="<%=basePath %>js/wysiwyg/jquery.hotkeys.js"></script>
  <script src="<%=basePath %>js/wysiwyg/bootstrap-wysiwyg.js"></script>
  <script src="<%=basePath %>js/wysiwyg/demo.js"></script>
 <script>
  $(document).ready(function(){
	selAllFriend();
});
	function selAllFriend(){
		debugger;
		var oval=document.getElementById("owner").value;
		var l = document.getElementById("myFriendList");
		l.innerHTML='';
		$.ajax( {
						url:'<%=basePath%>friend/findAllFriend',
						type:'post',
						data: {
							myEmail:oval
						},
						datatype : "json",//"xml", "html", "script", "json", "jsonp", "text".           
						success : function(data) {
							var json=eval('(' + data + ')');
							$.each(json, function (n, item) {
								
								addRow(n,item);
							});
							
							chooseFriend();
						},
						error : function() {
			                alert("异常！！！");
			                selAllFriend();	
			            }
				});
	}
	function addRow(n,item){
		
		
		var val = "<option value="+item.friend+" >"+item.nickname+"</option>";
		
		
		$("#myFriendList").append(val);
	}
	<!-- (这段js用来将下拉框中的放邮箱值得value赋值给表单框) -->
	function chooseFriend(){
    	<!-- (若点击好友列表跳转过来的需要默认给该好友发送信息在此进行判断)    -->
		var friend = '${friend.friend}';
		if(friend!=null&&friend!=''){
			document.getElementById("myFriendList").value = friend;
		}
		var title='${email.title}';
		if(title!=null&&title!=''){
			document.getElementById("title").value = title;
		}
		var content='${email.content}';
		if(content!=null&&content!=''){
			document.getElementById("editor").innerText = content;
		}
		var receiveMan='${email.receiveMan}';
		if(receiveMan!=null&&receiveMan!=''){
			document.getElementById("myFriendList").value = receiveMan;
		}
		var id='${email.id}';
		if(id!=null&&id!=''){
			document.getElementById("id").value = id;
		}

    debugger;
    var myselect=document.getElementById("myFriendList");

    var index=myselect.selectedIndex ;
    var ll = myselect.options[index].value;
    var e = document.getElementById("receiveMan");
    e.value=ll;


  }
</script>
</html>